@extends('layout.index')
@section('title','商品列表')
@section('content')
<div class="row">
    <div class="col-lg-12">
        <h1 class="page-header">订单列表</h1>
    </div>
    <!-- /.col-lg-12 -->
</div>
<div class="row">
    <div class="col-lg-12">
        <div class="panel panel-default">
            <div class="panel-heading">
            </div>
            <!-- /.panel-heading -->
            <div class="panel-body">
                <div class="dataTable_wrapper">
                    <div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
	                    <form action="{{url('/admin/indent/index')}}" method="get">
		                    <div class="row">
			                    <div class="col-sm-6">
				                    <div class="dataTables_length" id="dataTables-example_length">
				                    	<label>显示 <select name="num" aria-controls="dataTables-example" class="form-control input-sm">
					                    	<option value="10"
											@if(!empty($request['num']) && $request['num'] == 10)
												selected
											@endif
					                    	>10</option>
					                    	<option value="25"
											@if(!empty($request['num']) && $request['num'] == 25)
												selected
											@endif
					                    	>25</option>
					                    	<option value="50"
											@if(!empty($request['num']) && $request['num'] == 50)
												selected
											@endif
					                    	>50</option>
					                    	<option value="100"
											@if(!empty($request['num']) && $request['num'] == 100)
												selected
											@endif
					                    	>100</option>
				                    	</select> 条</label>
				                    </div>
		                    	</div>
		                    	<div class="col-sm-6">
			                    	<div id="dataTables-example_filter" class="dataTables_filter">
				                    	<label>关键字:<input											
				                    		@if(!empty($request['keywords']))
				                    			 value="{{$request['keywords']}}"
											@endif
				                    	name="keywords" type="search" class="form-control input-sm" placeholder="" aria-controls="dataTables-example"> <button class="btn btn-info">搜索</button>
				                    	</label>
			                    	</div>
		                    	</div>
		                    </div>
	                    </form>
	                    </div>
	                    	<div class="row">
		                    	<div class="col-sm-12">
			                    	<table id="dataTables-example" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dataTables-example_info">
				                        <thead>
					                        <tr role="row">
						                        <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 50px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">id</th>
						                        <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 80px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">用户</th>
						                        <th class="sorting_asc" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 80px;" aria-sort="ascending" aria-label="Rendering engine: activate to sort column descending">商品</th> 
						                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 181.2px;" aria-label="Browser: activate to sort column ascending">订单</th>
						                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 80px;" aria-label="Browser: activate to sort column ascending">下单时间</th>
						                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 80px;" aria-label="Browser: activate to sort column ascending">是否付款</th>
						                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 60px;" aria-label="Browser: activate to sort column ascending">是否发货</th>
						                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 60px;" aria-label="Browser: activate to sort column ascending">完成状态</th>
						                        <th class="sorting" tabindex="0" aria-controls="dataTables-example" rowspan="1" colspan="1" style="width: 60px;" aria-label="Browser: activate to sort column ascending">操作</th> 
					                        </tr>   
					                    </thead>
				                        <tbody>   
					                        @foreach($indents as $k=>$v)   
							                    <tr class="gradeA odd" role="row">
						                            <td class="sorting_1 sid">{{$v->id}}</td>
						                            <td class="sorting_1">{{$v->uname}}</td>
						                            <td class="sorting_1">{{$v->gname}}</td>
						                            <td>{{$v->number}}</td>
						                            <td class="sorting_1">{{$v->time}}</td>
						                            <td class="sorting_1">{{$v->payment}}</td>
						                            <td class="sorting_1">{{$v->shipments}}</td>
						                            <td class="sorting_1">{{$v->cmplete}}</td>
						                            <td class="center">
							                            <button class="btn btn-warning btn-circle btn_delete" type="button"><i class="fa fa-times"></i></button>	
						                            </td>
							                    </tr>
						                	@endforeach
					                    </tbody>
				                    </table>
			                    </div>
		                    </div>
	                      	<div class="row"> 
							   	<div class="col-sm-8">
								    <div class="dataTables_paginate paging_simple_numbers" id="dataTables-example_paginate">
									    
								    </div>
						    	</div>
							</div>  	
 				 		</div>
                	</div>
                	<!-- /.table-responsive -->
           		</div>
            	<!-- /.panel-body -->
        	</div>
        	<!-- /.panel -->
    	</div>
    	<!-- /.col-lg-12 -->
	</div>
</div>
@endsection
@section('myjs')
	<script type="text/javascript">
		//获取删除按钮 绑定单击事件
		$('.btn_delete').click(function(){
			//获取id
			var id = $(this).parents('tr').find('.sid').html();
			var btn = $(this);
			//ajax post请求 会出现Token错误  csrf保护问题  500
			//发送ajax请求
			$.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		    }
		});
			$.post('{{url("/admin/indent/delete")}}',{id:id},function(data){
				if(data == 1){
					btn.parents('tr').remove();
				}else{
					return back();
				}
			});
		})
	</script>
@endsection


